/*
 * @Author: 杨超
 * @Date: 2021-08-19 09:31:21
 * @LastEditTime: 2021-11-12 15:59:07
 * @LastEditors: 杨超
 * @Description:
 */
const usePatrolsColums = () => {
    const columns = [
        {
            slot: 'number',
            attrs: {
                prop: 'number',
                label: '编号',
                width: '160',
                'show-overflow-tooltip': true
            }
        },
        {
            attrs: {
                prop: 'typeName',
                label: '巡查类型',
                'show-overflow-tooltip': true,
                'min-width': '160'
            }
        },
        {
            attrs: {
                prop: 'repetitionPeriod',
                label: '重复周期',
                'show-overflow-tooltip': true,
                width: '120'
            }
        },
        {
            attrs: {
                prop: 'deptName',
                label: '巡查部门',
                'show-overflow-tooltip': true,
                'min-width': '160'
            }
        },
        {
            attrs: {
                prop: 'highwayName',
                label: '公路名称',
                'show-overflow-tooltip': true,
                width: '160'
            }
        },
        {
            attrs: {
                prop: 'inspectSection',
                label: '巡查路段',
                'show-overflow-tooltip': true,
                'min-width': '160'
            }
        },
        {
            attrs: {
                prop: 'startDate',
                label: '任务生成日期',
                'show-overflow-tooltip': true,
                width: '140'
            }
        },
        {
            attrs: {
                prop: 'endDate',
                label: '任务截止日期',
                'show-overflow-tooltip': true,
                width: '140'
            }
        },
        {
            slot: 'statusName',
            attrs: {
                prop: 'statusName',
                label: '任务状态',
                width: '120',
                'show-overflow-tooltip': true
            }
        },
        {
            slot: 'handle',
            attrs: {
                label: '操作',
                width: '140',
                fixed: 'right'
            }
        }
    ]
    return {
        columns
    }
}

const usePatrols = (context = {}) => {
    const { $router: _router } = context
    const typeMap = {
        1: 'AddDailyNightTask',
        2: 'AddDailyNightTask',
        3: 'AddCulvertTask',
        4: 'AddBridgeTask',
        5: 'AddRoadbedTask',
        6: 'AddTunnelTask',
        7: 'AddTunnelTask',
        8: 'AddRoadworkTask'
    }
    const handleAddRecord = row => {
        _router.push({
            name: typeMap[row.type],
            query: {
                taskNumber: row.number,
                type: row.type,
                highwayCode: row.highwayCode,
                deptIds: row.deptId,
                startStake1: row.startStake1,
                endStake1: row.endStake1,
                startStake2: row.startStake2,
                endStake2: row.endStake2
            }
        })
    }
    return {
        handleAddRecord
    }
}

export { usePatrols, usePatrolsColums }
